import os
from app.decorators.checkMissingArgs import checkMissingArgs

class FileService:

    def __init__(self):
        self.basePath = os.getcwd();

    @checkMissingArgs()
    def get_file_path(self, path):
        file_path = os.path.join(self.basePath, path)
        if not os.path.exists(file_path):
            return None
        else:
            return os.path.join(self.basePath, path)


    @checkMissingArgs()
    def save_file(self, file, path):

        basePath = os.path.join(self.basePath, path)
        if not os.path.exists(basePath):
            os.makedirs(basePath)
        file.save(os.path.join(basePath, file.filename))
        return os.path.join(path, file.filename)

